objectdef Act
{
  
  ;############################################
  ;##
  ;##  DO NOT FUCK WITH THE FOLLOWING
  ;##
  ;############################################
  variable uint nextCheckT
  variable bool didAction

  variable bool inBurn

  variable uint silenceCastT

  variable uint lastAutoAtkToggle
  variable uint lastAssistT
  variable string lastAbilUsed

  variable bool petAlive
  variable bool petAttacking

  variable bool tgtNoPhy
  variable bool tgtNoSpi
  variable bool tgtNoCld
  variable bool tgtNoFir
  variable bool tgtNoArc
  variable bool tgtNoMen

  variable bool tgtFurious
  variable string cmbtFocus
  variable uint tgtFuriousT

  variable bool tgtTooPowerful
  
  variable bool CommandAssist
  
  method Initialize()
  {
    ;echo --- obj_Act:Initialize --- starting obj_Act
    This.didAction:Set[FALSE]
    This.tgtTooPowerful:Set[FALSE]
    This.didAction:Set[FALSE]
    This.inBurn:Set[FALSE]
    This.petAttacking:Set[FALSE]
    This.CommandAssist:Set[FALSE]
    if ${Me.HavePet}
    {
      This.petAlive:Set[TRUE]
      VGExecute /pet assistmealways
    }
    else
      This.petAlive:Set[FALSE]
  }
  
  method Shutdown()
  {
  }
  
  method changeNextT(float modT)
  {
    if ${This.nextCheckT}<${Math.Calc[${Script.RunningTime}+(${modT}*1000)]}
      This.nextCheckT:Set[${Math.Calc[${Script.RunningTime}+(${modT}*1000)]}]
  }
  
  method changeTgt(int64 tgtID)
  {
    Pawn[id, ${tgtID}]:Target
    This:changeNextT[0.250]
  }
  
  member:bool isReady()
  {
    if ${This.nextCheckT} > ${Script.RunningTime}
      return FALSE
    return TRUE
  }
  method ResetTgt()
  {
    This.tgtNoPhy:Set[FALSE]
    This.tgtNoSpi:Set[FALSE]
    This.tgtNoCld:Set[FALSE]
    This.tgtNoFir:Set[FALSE]
    This.tgtNoArc:Set[FALSE]
    This.tgtNoMen:Set[FALSE]
    This.tgtFurious:Set[FALSE]
    This.petAttacking:Set[FALSE]
    This.tgtTooPowerful:Set[FALSE]
    This.CommandAssist:Set[FALSE]
    Mov.toggleRange:Set[FALSE]
  }
  
  ;############################################
  ;##
  ;##  THIS SHIT YOU CAN DICK AROUND WITH
  ;##
  ;############################################
  member:bool RotReady(string abilRot)
  {
    variable iterator abilIter
    variable bool RotIsReady
    RotIsReady:Set[FALSE]
    if ${Me.Class.NotEqual[Necromancer]} && ${Me.Class.NotEqual[Druid]} && ${Me.Class.NotEqual[Psionicist]} && ${Me.Class.NotEqual[Sorcerer]} && ${Me.Class.NotEqual[Bloodmage]}
      return FALSE
    switch ${abilRot}
    {
      case react
        reactRot:GetSettingIterator[abilIter]
        break
    }
    while ( ${abilIter.Key(exists)} || ${RotIsReady} )
    {
      if ${Me.Ability[${abilIter.Key}](exists)} && ${Me.Ability[${abilIter.Key}].IsReady} && !${Me.Ability[${abilIter.Key}].TimeRemaining}>0
        RotIsReady:Set[TRUE]  
      abilIter:Next
    }
    if ${RotIsReady}
      return TRUE
    return FALSE
  }
  
  method useAbil(string abilType, int64 tgt=0)
  {
    ;echo --- obj_Act:useAbil --- ${abilType}  -- to tgt ${tgt}
    variable iterator abilIter
    switch ${abilType}
    {
      case buff
        buffRot:GetSettingIterator[abilIter]
        break
      case combatbuff
        combatBuffRot:GetSettingIterator[abilIter]
        break
      case groupbuff
        groupBuffRot:GetSettingIterator[abilIter]
        break
      case healbig
        healBigRot:GetSettingIterator[abilIter]
        break
      case healmed
        healMedRot:GetSettingIterator[abilIter]
        break
      case healemg
        healEmgRot:GetSettingIterator[abilIter]
        break
      case healhot
        healHotRot:GetSettingIterator[abilIter]
        break
      case healgrp
        healGrpRot:GetSettingIterator[abilIter]
        break
      case canni
        canniRot:GetSettingIterator[abilIter]
        break
      case rez
        rezRot:GetSettingIterator[abilIter]
        break
      case debuff
        debuffRot:GetSettingIterator[abilIter]
        break
      case meleedebuff
        meleeDebuffRot:GetSettingIterator[abilIter]
        break
      case rangedebuff
        rangeDebuffRot:GetSettingIterator[abilIter]
        break
      case dot
        dotRot:GetSettingIterator[abilIter]
        break
      case meleedot
        meleeDotRot:GetSettingIterator[abilIter]
        break
      case rangedot
        rangeDotRot:GetSettingIterator[abilIter]
        break
      case melee
        meleeRot:GetSettingIterator[abilIter]
        break
      case range
        rangeRot:GetSettingIterator[abilIter]
        break
      case nuke
        nukeRot:GetSettingIterator[abilIter]
        break
      case react
        reactRot:GetSettingIterator[abilIter]
        break
      case AE
        AERot:GetSettingIterator[abilIter]
        break
      case rescue
        rescueRot:GetSettingIterator[abilIter]
        break
      case burn
        burnRot:GetSettingIterator[abilIter]
        break
      case burnbuff
        burnBuffRot:GetSettingIterator[abilIter]
        break
      case evasive
        evasiveRot:GetSettingIterator[abilIter]
        break
      case pull
        pullRot:GetSettingIterator[abilIter]
        break
      case special
        specPtsRot:GetSettingIterator[abilIter]
        break
      case hateToTank
        hateToTankRot:GetSettingIterator[abilIter]
        break
      case AEHateToTank
        AEHateToTankRot:GetSettingIterator[abilIter]
        break
      case dtgtdeaggro
        DTgtDeaggroRot:GetSettingIterator[abilIter]
        break
    }
    ;abilIter:First
    while ( ${abilIter.Key(exists)} && !${This.didAction} )
    {
      if ${Me.Class.Equal[Disciple]} && (${abilIter.Key.Equal[Endowment of Life]} || ${abilIter.Key.Equal[Endowment of Mastery]} || ${abilIter.Key.Equal[Endowment of Enmity]})
        This:dscCombatBuffLogic[${abilIter.Key}]
      elseif ${Me.Class.Equal[Ranger]} && ( ${abilIter.Key.Equal[Swelter]} ||  ${abilIter.Key.Equal[Sidesplit]} || ${abilIter.Key.Equal[Whisper of the Wind]} ) && ${Me.Target.Distance}<=5
        This:rngComboLogic[${abilIter.Key}]
      elseif ${Me.Class.Equal[Ranger]} && ( ${abilIter.Key.Equal[Static Surge]} || ${abilIter.Key.Equal[Crippling Poison]} || ${abilIter.Key.Equal[Deadeye]} ) && ${Me.Target.Distance}>5
        This:rngComboLogic[${abilIter.Key}]
      elseif ${abilType.Equal[canni]} && ${Me.Ability[${abilIter.Key}].TargetType.Equal[Offensive]} && !${Me.InCombat}
        return
      elseif ${abilIter.Key.Equal[Bane of Heaven]} && ( ${This.tgtTooPowerful} || !${Me.TargetAsEncounter.Difficulty.Equal[6]} || ${Me.Target.Level} < 57 )
        return
      elseif ${abilIter.Key.Find[Dusk Arrow]}
      {
        if !${This.TgtBuffCheck[${abilIter.Key}]}
        {
          ; dusk arrow exists
          if ${Mov.toggleRange}
          {
            Mov.toggleRange:Set[FALSE]
            ; echo ^^^ for dusk arrow, just set toggleRange to FALSE
            if ${Me.Target.Distance}>${moveToTargetDist}
              This.didAction:Set[TRUE]
          }
        }
        elseif ${Me.Target.Distance}>=6 && ${Me.Ability[${abilIter.Key}].IsReady}
          This:doUseAbil[${abilIter.Key}, ${tgt}, ${abilType}]
        elseif ${Me.Target.Distance} < 6
        {
          ; echo ### need to cast ${abilIter.Key}, setting toggleRange to TRUE ###
          This.didAction:Set[TRUE]
          Mov.toggleRange:Set[TRUE]
        }
      }
      elseif ${Me.Ability[${abilIter.Key}](exists)} && ${Me.Ability[${abilIter.Key}].IsReady} && !${Me.Ability[${abilIter.Key}].TimeRemaining}>0 && !${Me.Ability[${abilIter.Key}].Toggled}
      {
        if ${Me.Ability[${abilIter.Key}].TargetType.Equal[9]} && ${Pawn[name, corpse of](exists)} && !${Me.Effect[${abilIter.Key}](exists)}
          This:doUseAbil[${abilIter.Key}, ${Pawn[name, corpse of].ID}, ${abilType}]
        elseif ( ${Script.RunningTime}>=${This.silenceCastT} && ${Me.Ability[${abilIter.Key}].Type.Equal[Spell]} ) || !${Me.Ability[${abilIter.Key}].Type.Equal[Spell]}
          This:doUseAbil[${abilIter.Key}, ${tgt}, ${abilType}]
      }
      elseif ${Me.HavePet}
      {
        if ${Me.Pet.Ability[${abilIter.Key}](exists)}
        {
          if ${Me.Pet.Ability[${abilIter.Key}].IsReady}
          {
            ;echo Pet using ability ${abilIter.Key}
            Me.Pet.Ability[${abilIter.Key}]:Use
            This:changeNextT[0.250]
          }
        }
      }
      if ${abilType.Equal[burnbuff]} && ${This[parent].didAction}
        This.didAction:Set[FALSE]
      abilIter:Next
    }
  }
  
  method doUseAbil(string abilName, int64 tgt=0, string abilType="melee")
  {
    ; echo @@@ doUseAbil @@@ ${abilName} ${tgt} ${abilType}
    This:changeNextT[0.250]
    variable int64 abilTgt
    ; ======== TARGET?  ABILITY READY?
    if !${Me.Ability[${abilName}](exists)} || !${Me.Ability[${abilName}].IsReady}
        return
    ;========= SET TGT ID FIRST for TIMERS ======
    if ( ${Me.Ability[${abilName}].TargetType.Equal[Self]} || ${Me.Ability[${abilName}].TargetType.Equal[Defensive]} || ${Me.Ability[${abilName}].TargetType.Equal[Group]} || ${Me.Ability[${abilName}].TargetType.Equal[12]} ) && ${tgt}==0
      abilTgt:Set[${Me.ToPawn.ID}]
    elseif ${Me.Ability[${abilName}].TargetType.Equal[Offensive]}
      abilTgt:Set[${Me.Target.ID}]
    elseif ${Pawn[id, ${tgt}](exists)}
      abilTgt:Set[${tgt}]
    if !${Pawn[id, ${abilTgt}].HaveLineOfSightTo}
      return
    ;========= CHECK BUFF/DEBUFF LIST OR TIMER ======
    if ${LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS].FindSetting[${abilName}](exists)} || ( ${Me.IsGrouped} && ${This.HasDefaultTimer[${abilName}]} )  
    {
      ;echo ${abilName} ability has a timer, checking to see if we should cast
      if !${This.ManageTimers[${abilName}, ${abilTgt}]}
        return
    }
    elseif !${abilType.Find[heal]} && !${abilType.Equal["nuke"]} && !${abilType.Equal["melee"]} && !${This.TgtBuffCheck[${abilName}]}
      return
    ;============ CHECK COSTS (also checks range to tgt) ===================
    if !${This.AbilCostCheck[${abilName}]}
      return
    ;============ CHECK MOB HEALING ====================
    if ${This.WillAbilHealMob[${abilName}, ${Me.Target.Name}]}
      return
    ;================ CAN USE THE ABILITY, NOW CHECK FOR FORMS ==========
    This:CombatStances[${abilType}]
    ;================ FORMS DONE, DO WE HAVE THE RIGHT WEAPON SET? ==========
    if ${doWS}
      This:WeaponSets[${abilType}]
    ;============== CHANGE TARGET IF NEEDED =============
    if !${Me.Ability[${abilName}].TargetType.Equal[Offensive]} && !${Me.Ability[${abilName}].TargetType.Equal[Self]} && ${tgt}!=0
    {
      ; self automatically hits self, offensive automatically hits offensive
      if ${Me.DTarget.ID}!=${tgt}
        This:changeTgt[${tgt}]
    }
    elseif ${Me.Ability[${abilName}].TargetType.Equal[Offensive]} && ${tgt}!=0 && ${tgt}!=${Me.Target.ID}
    {
      if ${Me.DTarget.ID}!=${tgt}
        This:changeTgt[${tgt}]
       ; included for forcing in dtgts on detrimental abilities
    }
    ;if ${Me.Class.Equal[Bard]} && ( ${doNuke} || ${doDots} )
    ;{
    ;  if ${doNuke} && ${Me.EnergyPct}>=${enerNukePct}
    ;  {
    ;    if ${Me.Ability[Eaon's Booming Bellow].IsReady} && !${This.WillAbilHealMob["Eaon's Booming Bellow", ${Me.Target.Name}]}
    ;    {
    ;      echo ---obj_Act: using ability Eaon's Booming Bellow on ${Me.Target.Name}
    ;      Me.Ability[Eaon's Booming Bellow]:Use
    ;    }
    ;    if ${Me.Ability[Eaon's Superior Blasting Bellow].IsReady} && !${This.WillAbilHealMob["Eaon's Superior Blasting Bellow", ${Me.Target.Name}]}
    ;    {
    ;      echo ---obj_Act: using ability Eaon's Superior Blasting Bellow on ${Me.Target.Name}
    ;      Me.Ability[Eaon's Superior Blasting Bellow]:Use
    ;    }
    ;  }
    ;  if ${doDots} && ${Me.EnergyPct}>=${enerDOTPct}
    ;  {
    ;    echo ---obj_Act: bard dots before main abil usage.
    ;    if ${Me.Ability[Fasant's Chant of Corruption III].IsReady} && ${This.TgtBuffCheck["Fasant's Chant of Corruption III"]} && !${This.WillAbilHealMob["Fasant's Chant of Corruption III", ${Me.Target.Name}]}
    ;    {
    ;      echo ---obj_Act: using ability Fasant's Chant of Corruption III on ${Me.Target.Name}
    ;      Me.Ability[Fasant's Chant of Corruption III]:Use
    ;    }
    ;    elseif ${Me.Ability[Fasant's Chant of the Flame III].IsReady} && ${This.TgtBuffCheck["Fasant's Chant of the Flame III"]} && !${This.WillAbilHealMob["Fasant's Chant of the Flame III", ${Me.Target.Name}]}
    ;    {
    ;      echo ---obj_Act: using ability Fasant's Chant of the Flame III on ${Me.Target.Name}
    ;      Me.Ability[Fasant's Chant of the Flame III]:Use
    ;    }
    ;    elseif ${Me.Ability[Fasant's Chant of Winter III].IsReady} && ${This.TgtBuffCheck["Fasant's Chant of Winter III"]} && !${This.WillAbilHealMob["Fasant's Chant of Winter III", ${Me.Target.Name}]}
    ;    {
    ;      echo ---obj_Act: using ability Fasant's Chant of Winter III on ${Me.Target.Name}
    ;      Me.Ability[Fasant's Chant of Winter III]:Use
    ;    }
    ;  } 
    ;}
    Me.Ability[${abilName}]:Use
    if !${noGCDList.FindSetting[${abilName}](exists)}
    {
      This.didAction:Set[TRUE]
      This:changeNextT[${Math.Calc[${Me.Ability[${abilName}].CastTime}+0.500]}]
    }
    else
    {
      ; all no GCDs have 0 cast times. Heals require a packet update.
      if ${abilType.Find[heal]}
        This:changeNextT[0.500]
      else
        This:changeNextT[0.125]
    }
    echo ---obj_Act: using ability ${abilName} of type ${abilType} on tgt ${abilTgt} nextCheckT ${This.nextCheckT}
    if ${LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS].FindSetting[${abilName}](exists)}
    {
      ;echo ### doUseAbil routine ### adding timers from library
      if ${Me.IsGrouped} && ( ${Me.Ability[${abilName}].TargetType.Equal[Group]} || ${Me.Ability[${abilName}].TargetType.Equal[Raid]} ||${Me.Ability[${abilName}].TargetType.Equal[12]} ) 
        This:GroupBuffTimerLogic[${abilName}, ${LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS].FindSetting[${abilName}]}]
      else
        This:AddTimers[${abilName}, ${abilTgt}, ${LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[TIMERS].FindSetting[${abilName}]}]
    }
    elseif ${This.HasDefaultTimer[${abilName}]} && ${Me.IsGrouped}
      This:GroupBuffTimerLogic[${abilName}, 3600]
  }
  
  method CombatStances(string abilType)
  {
    if ${doTankStance} && ${Tank.Equal[${Me.FName}]}
      This:doCombatStances[${tankStance}]
    else
    {
      if ${abilType.Equal[evasive]} && ${doEvasiveStance}
        This:doCombatStances[${evasiveStance}]
      elseif ${abilType.Equal[burn]} && ${doBurnStance}
        This:doCombatStances[${burnStance}]
      elseif ( ${abilType.Equal[nuke]} || ${abilType.Equal[dot]} ) && ${doSpellStance}
        This:doCombatStances[${spellStance}]
      elseif ${abilType.Find[heal]} && ${doHealStance}
        This:doCombatStances[${healStance}]
      elseif ${abilType.Find[melee]} && ${doMeleeStance}
        This:doCombatStances[${meleeStance}]
      elseif ${abilType.Find[special]} && ${doSpecPtsStance}
        This:doCombatStances[${specPtsStance}]
      elseif ${abilType.Find[canni]} && ${doCanniStance}
        This:doCombatStances[${canniStance}]
    }
  }
  
  method doCombatStances(string stanceType)
  {
    if !${Me.Form[${stanceType}](exists)}
      return
    if ${Me.Form[${stanceType}].IsReady} && ${Me.CurrentForm.Name.NotEqual[${stanceType}]}
    {
      Me.Form[${stanceType}]:ChangeTo
      This:changeNextT[0.125]
    }
  }
  
  method WeaponSets(string abilType)
  {
    if ${Me.FName.Equal[${Tank}]}
      This:doWeaponSets[tank]
    elseif ${abilType.Equal[canni]}
      This:doWeaponSets[canni]
    elseif ${abilType.Find[heal]}
      This:doWeaponSets[heal]
    elseif ${abilType.Find[mel]}
      This:doWeaponSets[melee]
    elseif ${abilType.Equal[nuke]} || ${abilType.Equal[dot]} || ${abilType.Equal[debuff]}
      This:doWeaponSets[spell]
    elseif ${abilType.Find[rang]}
      This:doWeaponSets[range]
    elseif ${abilType.Find[react]}
      This:doWeaponSets[react]
    elseif ${abilType.Find[burn]}
      This:doWeaponSets[burn]
  }
  
  method doWeaponSets(string wpnSet)
  {
    variable string tempTxt
    if !${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}](exists)}
      return
    if ${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[primary](exists)}
    {
      tempTxt:Set[${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[primary]}]
      if ( !${Me.Inventory[CurrentEquipSlot, "Primary Hand"](exists)} || !${Me.Inventory[CurrentEquipSlot, "Primary Hand"].Name.Equal[${tempTxt.Replace["#",","]}]} || ( ${Me.Inventory[CurrentEquipSlot, Two Hands](exists)} && !${Me.Inventory[CurrentEquipSlot, "Two Hands"].Name.Equal[${tempTxt.Replace["#",","]}]} ) ) && ${Me.Inventory[${tempTxt.Replace["#",","]}](exists)}
        This:doChangeWeapons[${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[primary]}, "Primary Hand"]
    }
    if ${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[offhand](exists)}
    {
      tempTxt:Set[${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[offhand]}]
      if ( !${Me.Inventory[CurrentEquipSlot, "Secondary Hand"](exists)} || !${Me.Inventory[CurrentEquipSlot, "Secondary Hand"].Name.Equal[${tempTxt.Replace["#",","]}]} || ( ${Me.Inventory[CurrentEquipSlot, Two Hands](exists)} && !${Me.Inventory[CurrentEquipSlot, "Two Hands"].Name.Equal[${tempTxt.Replace["#",","]}]} ) ) && ${Me.Inventory[${tempTxt.Replace["#",","]}](exists)}
        This:doChangeWeapons[${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[offhand]}, "Secondary Hand"]
    }
    if ${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[ranged](exists)}
    {
      tempTxt:Set[${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[ranged]}]
      if ( !${Me.Inventory[CurrentEquipSlot, "Ranged"](exists)} || !${Me.Inventory[CurrentEquipSlot, "Ranged"].Name.Equal[${tempTxt.Replace["#",","]}]} ) && ${Me.Inventory[${tempTxt.Replace["#",","]}](exists)}
        This:doChangeWeapons[${LavishSettings[ezvg].FindSet[WeaponSets].FindSet[${wpnSet}].FindSetting[ranged]}, "Ranged"]
      elseif ${tempTxt.Equal[Emerald Leaf Shuriken]}
        This:doChangeWeapons[${tempTxt}, ranged]
      elseif ${tempTxt.Equal[Drake Fang Shuriken]}
        This:doChangeWeapons[${tempTxt}, ranged]
    }
  }
  
  method doChangeWeapons(string weapon, string slot)
  {
    if ${weapon.Equal[Emerald Leaf Shuriken]} && !${Me.Inventory[${weapon}](exists)}
    {
      if ${Me.Inventory[Tam Thi's Gift](exists)} && ${Me.Inventory[Tam Thi's Gift].IsHotkeyed} && ${Me.Inventory[Tam Thi's Gift].IsReady}
        This:doUseItem[Tam Thi's Gift, ${Me.ToPawn.ID}]
    }
    elseif ${weapon.Equal[Drake Fang Shuriken]} && !${Me.Inventory[${weapon}](exists)}
    {
      if ${Me.Inventory[Mystical Drake Fang](exists)} && ${Me.Inventory[Mystical Drake Fang].IsHotkeyed} && ${Me.Inventory[Mystical Drake Fang].IsReady}
        This:doUseItem[Mystical Drake Fang, ${Me.ToPawn.ID}]
    }
    else
    {
      ;echo ### WS ### using inventory method for ${slot} item ${weapon}
      if ${slot.Equal[Primary Hand]}
      {
        VGExecute /wear \"${weapon.Replace["#", ","]}\" primaryhand
      }
      elseif ${slot.Equal[Secondary Hand]}
        VGExecute /wear \"${weapon.Replace["#", ","]}\" secondaryhand
      else
        VGExecute /wear \"${weapon.Replace["#", ","]}\"
    }
    This:changeNextT[0.250]
  }
  
  member:bool HasDefaultTimer(string abilName)
  {
    ;echo %%% HasDefaulTimer %%% ${abilName} ${abilName.Left[7].Equal[Scaling]} ${abilName.Left[4].Equal[Mass]}
    if ${abilName.Left[7].Equal[Scaling]} || ${abilName.Left[4].Equal[Mass]}
    {
      ;echo %%% HasDefaultTimer %%% returning true
      return TRUE
    }
    ;echo %%% HasDefaultTimer %%% returning false
    return FALSE
  }
  
  member:bool ManageTimers(string abilName, int64 abilTgt)
  {
    ; so we know the ability is on a timer, now we need to check if it's on the mob
    if !${LavishSettings[Timers].FindSet[${abilTgt}](exists)}
      return TRUE
    if !${LavishSettings[Timers].FindSet[${abilTgt}].FindSetting[${abilName}](exists)}
      return TRUE
    else
    {
      ;echo --- TIMERS --- found timer for abil ${abilName} current T is ${Script.RunningTime} and next T is ${LavishSettings[Timers].FindSet[${abilTgt}].FindSetting[${abilName}]} 
      if ${LavishSettings[Timers].FindSet[${abilTgt}].FindSetting[${abilName}]}>${Script.RunningTime}
        return FALSE
      else
        return TRUE
    }
  }
  
  method AddTimers(string abilName, int64 abilTgt, int abilTimer)
  {
    variable uint newT
    newT:Set[${Math.Calc[${Script.RunningTime}+${abilTimer}*1000]}]
    echo adding timer to ${abilTgt} with abil ${abilName} next castT is ${newT} vs current of ${Script.RunningTime}
    if !${LavishSettings[Timers].FindSet[${abilTgt}](exists)}
      LavishSettings[Timers]:AddSet[${abilTgt}]
    if !${LavishSettings[Timers].FindSet[${abilTgt}].FindSetting[${abilName}](exists)}
      LavishSettings[Timers].FindSet[${abilTgt}]:AddSetting[${abilName}, ${newT}]
    else
      LavishSettings[Timers].FindSet[${abilTgt}].FindSetting[${abilName}]:Set[${newT}]
    
  }
  
  method GroupBuffTimerLogic(string aName, int aTimer)
  {
    variable int grpIter
    grpIter:Set[1]
    do
    {
      if ${Me.FName.Equal[${Group[${grpIter}]}]}
        This:AddTimers[${aName}, ${Me.ToPawn.ID}, ${aTimer}]
      elseif ${Pawn[ID, ${Group[${grpIter}].ID}].Distance}<25
        This:AddTimers[${aName}, ${Group[${grpIter}].ID}, ${aTimer}]
      grpIter:Inc[1]
    }
    while ${Group[${grpIter}](exists)}
  }
  
  member:bool AbilCostCheck(string abilName)
  {
    if ${Me.Ability[${abilName}].EnergyCost(exists)} && ${Me.Ability[${abilName}].EnergyCost}>${Me.Energy}
      return FALSE
    if ${Me.Ability[${abilName}].EnergyCost(exists)} && ${Me.Target.Name.Equal[ARACHNIDON SUNSHINE]} && ${Me.TargetHealth}<35
      return FALSE
    if ${Me.Ability[${abilName}].HealthCost(exists)} && ${Me.Ability[${abilName}].HealthCost}>${Me.Health}
      return FALSE
    if ${Me.Ability[${abilName}].EnduranceCost(exists)} && ${Me.Ability[${abilName}].EnduranceCost}>${Me.Endurance}
      return FALSE
    if ${Me.Ability[${abilName}].JinCost(exists)} || ${Me.Ability[${abilName}].PhenomenaPointsCost(exists)} || ${Me.Ability[${abilName}].VirtuePointsCost(exists)}
    {
      if !${This.SpecPtsCostCheck[${abilName}]}
        return FALSE
    }
    if !${Me.Ability[${abilName}].TargetInRange} && !${Me.Ability[${abilName}].TargetType.Equal[Self]}
      return FALSE
    return TRUE
  }
  
  member:bool SpecPtsCostCheck(string abilName)
  {
    if ${Me.Ability[${abilName}].JinCost(exists)} && ${Me.Ability[${abilName}].JinCost}>${Me.Stat[Adventuring,Jin]}
      return FALSE
    elseif ${Me.Ability[${abilName}].PhenomenaPointsCost(exists)} && ${Me.Ability[${abilName}].PhenomenaPointsCost}>${Me.Stat[Adventuring,Phenomia Points]}
      return FALSE
    elseif ${Me.Ability[${abilName}].VirtuePointsCost(exists)} && ${Me.Ability[${abilName}].VirtuePointsCost}>${Me.Stat[Adventuring,Virtue Points]}
      return FALSE
    return TRUE
  }

  member:bool WillAbilHealMob(string abilName, string tName)
  {
    if ${This.WillGENAbilHealMob[${abilName}, ${tName}]}
      return TRUE
    if ${This.WillSpellAbilHealMob[${abilName}, ${tName}]}
      return TRUE
    return FALSE
  }
  
  member:bool WillGENAbilHealMob(string abilName, string tName)
  {
    if ${LavishSettings[AbilDict].FindSet[${Me.Class}].FindSet[${LavishSettings[MobDict].FindSet[${tName}].FindSetting[HealsTo]}].FindSetting[${abilName}](exists)}
      return TRUE
    return FALSE
  }
  
  member:bool WillSpellAbilHealMob(string abilName, string tName)
  {
    variable string mobWillHealTo
    mobWillHealTo:Set[${LavishSettings[MobDict].FindSet[${tName}].FindSetting[HealsTo]}]
    if ${Me.Ability[${abilName}].School.Token[1, " "].Equal[Physical]} && ( ${This.tgtNoPhy} || ${mobWillHealTo.Equal[PHY]} )
      return TRUE
    elseif ${Me.Ability[${abilName}].School.Token[1, " "].Equal[Spiritual]} && ( ${This.tgtNoSpi} || ${mobWillHealTo.Equal[SPI]} )
      return TRUE
    elseif ${Me.Ability[${abilName}].School.Token[1, " "].Equal[Fire]} && ( ${This.tgtNoFir} || ${mobWillHealTo.Equal[FIR]} )
      return TRUE
    elseif ${Me.Ability[${abilName}].School.Token[1, " "].Equal[Cold]} && ( ${This.tgtNoCld} || ${mobWillHealTo.Equal[CLD]} )
      return TRUE
    elseif ${Me.Ability[${abilName}].School.Token[1, " "].Equal[Arcane]} && ( ${This.tgtNoArc} || ${mobWillHealTo.Equal[ARC]} )
      return TRUE
    elseif ${Me.Ability[${abilName}].School.Token[1, " "].Equal[Mental]} && ( ${This.tgtNoMen} || ${mobWillHealTo.Equal[MEN]} )
      return TRUE
    else
      return FALSE
  }
  
  member:bool TgtBuffCheck(string abilName)
  {
    echo --- obj_Act.TgtBuffCheck ${abilName}
    if ${This.inBurn} && ${Me.Class.Equal[Ranger]} && ( ${abilName.Equal[Swelter]} ||  ${abilName.Equal[Sidesplit]} || ${abilName.Equal[Whisper of the Wind]} )
      return TRUE
    if ${This.inBurn} && ${Me.Class.Equal[Ranger]} && ( ${abilName.Equal[Static Surge]} || ${abilName.Equal[Crippling Poison]} || ${abilName.Equal[Deadeye]} )
      return TRUE
    if ${This.inBurn} && ${Me.Ability[${abilName}].TargetType.Equal[Offensive]}
      return TRUE
    ;if ${Me.TargetWeakness[${abilWeaknessDict[${abilName}]}](exists)}
    ;  return TRUE
    if ${Me.TargetMyDebuff[${abilName}](exists)} || ${Me.TargetMyDebuff[${abilName} (Modified)](exists)} || ${Me.Effect[${abilName}](exists)}
      return FALSE
    if ${abilName.Find[Scaling]}
    {
      if ${Me.Effect[${abilName.Right[${Math.Calc[${abilName.Length}-7]}]}](exists)}
        return FALSE
      elseif ${Me.Effect[${abilName.Right[${Math.Calc[${abilName.Length}-7]}]} I](exists)}
        return FALSE
      elseif ${Me.Effect[${abilName.Right[${Math.Calc[${abilName.Length}-7]}]} II](exists)}
        return FALSE
      elseif ${Me.Effect[${abilName.Right[${Math.Calc[${abilName.Length}-7]}]} III](exists)}
        return FALSE
      elseif ${Me.Effect[${abilName.Right[${Math.Calc[${abilName.Length}-7]}]} IV](exists)}
        return FALSE
      elseif ${Me.Effect[${abilName.Right[${Math.Calc[${abilName.Length}-7]}]} V](exists)}
        return FALSE
      elseif ${Me.Effect[${abilName.Right[${Math.Calc[${abilName.Length}-7]}]} VI](exists)}
        return FALSE
      ;echo @@@ TgtBuff Check @@@ Scaling Buff and did not find the buff
      return TRUE
    }
    elseif ${abilName.Find[Mass]}
    {
      if ${Me.Effect[${abilName.Right[${Math.Calc[${abilName.Length}-4]}]}](exists)}
        return FALSE
      ;echo @@@ TgtBuff Check @@@ Mass Buff and did not find the buff
      return TRUE
    }
    return TRUE
  }
  
  method useItem(string itemType)
  {
    variable iterator itemIter
    switch ${itemType}
    {
      case buff
        itemBuffRot:GetSettingIterator[itemIter]
        break
      case burnitem
        burnItemBuffRot:GetSettingIterator[itemIter]
        break
      case burnconsumeitem
        burnConsumableItemBuffRot:GetSettingIterator[itemIter]
        break
      case otgt
        itemOTgtRot:GetSettingIterator[itemIter]
        break
      case assist
        itemAssistRot:GetSettingIterator[itemIter]
        break
      case tank
        itemTankRot:GetSettingIterator[itemIter]
        break
      case canni
        itemCanniRot:GetSettingIterator[itemIter]
        break
    }
    itemIter:First
    while ( ${itemIter.Key(exists)} && !${This.didAction} )
    {
      if !${Me.Effect[${itemIter.Key}](exists)} && ${Me.Inventory[${itemIter.Key}](exists)} && ${Me.Inventory[${itemIter.Key}].IsHotkeyed}
      {
        if ${Me.Inventory[${itemIter.Key}].IsReady}
        {
          if ${itemType.NotEqual[assist]} && ${itemType.NotEqual[tank]}
            This:doUseItem[${itemIter.Key}, ${Me.ToPawn.ID}]
          elseif ${itemType.Equal[assist]}
            This:doUseItem[${itemIter.Key}, ${AssistID}]
          elseif ${itemType.Equal[tank]}
            This:doUseItem[${itemIter.Key}, ${TankID}]
        }
      }
      if ( ${itemType.Equal[burnitem]} || ${itemType.Equal[burnconsumeitem]} ) && ${This.didAction}
        This.didAction:Set[FALSE]
      itemIter:Next
    }
  }
  
  method doUseItem(string itemName, int64 tgtID=0)
  {
    if ${tgtID}>0
    {
      if ${Pawn[ID, ${tgtID}](exists)}
      {
        if ${Pawn[ID, ${tgtID}].Distance}>25 || !${Pawn[ID, ${tgtID}].HaveLineOfSightTo}
          return
        elseif ${Me.DTarget.ID}!=${tgtID} && ${Me.Target.ID}!=${tgtID}
          This:changeTgt[${tgtID}]
      }
      if ${tgtID.Equal[${Me.Target.ID}]} || ${tgtID.Equal[${Me.DTarget.ID}]} 
      {
        if ${LavishSettings[ItemsDict].FindSet[${itemName}](exists)}
        {
          if ${LavishSettings[ItemsDict].FindSet[${itemName}].FindSetting[BuffsAs](exists)}
          {
            if ${This.ItemTgtBuffCheck[${LavishSettings[ItemsDict].FindSet[${itemName}].FindSetting[BuffsAs]}]}
            {
              Me.Inventory[${itemName}]:Use
              This.didAction:Set[TRUE]
              This:changeNextT[0.250]
            }
          }
        }
        else
        {
          Me.Inventory[${itemName}]:Use
          This.didAction:Set[TRUE]
          This:changeNextT[0.250]
        }
      }
    }
  }
  
  member:bool ItemTgtBuffCheck(string itemBuff)
  {
    ;echo --- checking if itemBuff ${itemBuff} exists
    if ${Me.TargetMyDebuff[${itemBuff}](exists)} || ${Me.TargetMyDebuff[${itemBuff} (Modified)](exists)} || ${Me.Effect[${itemBuff}](exists)}
      return FALSE
    return TRUE
  }
  
  method useAutoAtk()
  {
    ;echo ### useAutoAtk ${Script.RunningTime} vs. ${This.lastAutoAtkToggle}
    if ${Script.RunningTime}>${This.lastAutoAtkToggle}
    {
      ;echo ### useAutoAtk --- using auto attack
      This:changeNextT[0.125]
      This.lastAutoAtkToggle:Set[${Math.Calc[${Script.RunningTime} + 1000]}]
      Me.Ability[Auto Attack]:Use
      if ${This.petAttacking} && ${Me.HavePet}
      {
        VGExecute /pet backoff
        This.petAttacking:Set[FALSE]
      }
      if ${Me.Minion}>0
        VGExecute /minions backoff
    }
  }
  
  ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  ;@@
  ;@@      OTHER LOGIC
  ;@@
  ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  method dscCombatBuffLogic(string cBuff)
  {
    if ${cBuff.Equal[Endowment of Mastery]} && !${Me.Effect[Endowment of Mastery](exists)}
    {
      if ${This.lastAbilUsed.Equal[Void Hand VII]}
      {
        This:doUseAbil["Knife Hand IV"]
        if ${This.didAction}
          This.lastAbilUsed:Set[""]
      }
      elseif ${This.lastAbilUsed.Equal[Soul Cutter VI]}
      {
        This:doUseAbil["Void Hand VII"]
        if ${This.didAction}
          This.lastAbilUsed:Set[Void Hand VII]
      }
      else
      {
        This:doUseAbil["Soul Cutter VI"]
        if ${This.didAction}
          This.lastAbilUsed:Set[Soul Cutter VI]
      }
    }
    elseif ${cBuff.Equal[Endowment of Enmity]} && !${Me.Effect[Endowment of Enmity](exists)}
    {
      if ${This.lastAbilUsed.Equal[Cyclone Kick V]}
      {
        This:doUseAbil["Ra'Jin Flare III"]
        if ${This.didAction}
          This.lastAbilUsed:Set[]
      }
      else
      {
        This:doUseAbil["Cyclone Kick V"]
        if ${This.didAction}
          This.lastAbilUsed:Set[Cyclone Kick V]
      }
    }
    elseif ${cBuff.Equal[Endowment of Life]} && ${This.ManageTimers["Endowment of Life", ${TankID}]}
    {
      if !${Pawn[id, ${TankID}](exists)}
        return
      else
      {
        if ${This.lastAbilUsed.Equal[Cyclone Kick V]}
        {
          ;echo ### DISC CBUFFS ### Step 3 of 3
          This:doUseAbil["Void Hand VII", ${TankID}]
          if ${This.didAction} && ${Me.DTarget.ID.Equal[${TankID}]}
          {
            This:AddTimers["Endowment of Life", ${TankID}, 90]
            This.lastAbilUsed:Set[]
          }
        }
        elseif ${This.lastAbilUsed.Equal[Blessed Wind VII]}
        {
          This:doUseAbil["Cyclone Kick V", ${TankID}]
          if ${This.didAction} && ${Me.DTarget.ID.Equal[${TankID}]}
            This.lastAbilUsed:Set[Cyclone Kick V]
        }
        else
        {
          This:doUseAbil["Blessed Wind VII", ${TankID}]
          if ${This.didAction} && ${Me.DTarget.ID.Equal[${TankID}]}
            This.lastAbilUsed:Set[Blessed Wind VII]
        }
      } 
    }
  }

  method rngComboLogic(string combo)
  {
    ; echo ~~~ rngComboLogic ~~~ ${combo}
    ; swelter fire dot (all melee, need melee stance)
    ; if ranger, meleeDots and !swelter, no mob healing
    ; static shock arc dot (all range)
    ; if ranger, rangeDots and !static shock exists, no mob healing
    ; crippling shot phy dot (all range, need range stance)
    ; if ranger, if in ranged stance and !crippling shot exists, no mob healing
    if ${This.WillAbilHealMob[${combo}, ${Me.Target.Name}]} || !${This.TgtBuffCheck[${combo}]}
      return
    ; swelter requires melee stance
    if ${combo.Equal[Swelter]} && ( !${doMeleeStance} || ( ${Me.CurrentForm.Name.NotEqual[Offensive Style]} && !${Me.Form[Offensive Style].IsReady} ) )
      return
    ; crippling poison requires range stance
    if ${combo.Equal[Crippling Poison]} && ( !${doRangeStance} || ( ${Me.CurrentForm.Name.NotEqual[Style of Precision]} && !${Me.Form[Style of Precision].IsReady} ) )
      return
    if ${doRangeStance} && ${combo.Equal[Crippling Poison]} && ${Me.Target.Distance}<6
    {
      if ${combo.Equal[Crippling Poison]} && ${Me.CurrentForm.Name.NotEqual[Style of Precision]}
        Me.Form[Style of Precision]:ChangeTo
    }
    elseif ${doMeleeStance} && ${combo.Equal[Swelter]} && ${Me.Target.Distance}>5
    {
      if ${Me.CurrentForm.Name.NotEqual[Offensive Style]}
        Me.Form[Offensive Style]:ChangeTo
    }
    if ${combo.Equal[Swelter]}
    {
      ; in reverse order = blade of summer v, blade of winter vi, cripple v
      if ${This.lastAbilUsed.Equal[Blade of Winter VI]}
      {
        This:doUseAbil["Blade of Summer V", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[]
      }
      elseif ${This.lastAbilUsed.Equal[Cripple V]}
      {
        This:doUseAbil["Blade of Winter VI", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[Blade of Winter VI]
      }
      else
      {
        This:doUseAbil["Cripple V", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[Cripple V]
      }
    }
    elseif ${combo.Equal[Static Surge]}
    {
      ; in reverse order = deadly shot v, shocking arrow v, critical shot v
      if ${This.lastAbilUsed.Equal[Shocking Arrow V]}
      {
        This:doUseAbil["Deadly Shot V", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[]
      }
      elseif ${This.lastAbilUsed.Equal[Critical Shot V]}
      {
        This:doUseAbil["Shocking Arrow V", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[Shocking Arrow V]
      }
      else
      {
        This:doUseAbil["Critical Shot V", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[Critical Shot V]
      }
    }
    elseif ${combo.Equal[Crippling Poison]}
    {
      ; in reverse order = poison shot iv, debilitating shot ii, crippling shot v
      if ${This.lastAbilUsed.Equal[Debilitating Shot II]}
      {
        This:doUseAbil["Poison Shot IV", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[]
      }
      elseif ${This.lastAbilUsed.Equal[Crippling Shot V]}
      {
        This:doUseAbil["Debilitating Shot II", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[Debilitating Shot II]
      }
      else
      {
        This:doUseAbil["Crippling Shot V", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[Crippling Shot V]
      }
    }
    elseif ${combo.Equal[Sidesplit]}
    {
      if ${This.lastAbilUsed.Equal[Debilitating Shot II]}
      {
        This:doUseAbil["Blade of Summer V", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[]
      }
      else
      {
        This:doUseAbil["Blade of Summer V", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[Blade of Summer V]
      }
    }
    elseif ${combo.Equal[Deadeye]}
    {
      if ${This.lastAbilUsed.Equal[Deadly Shot V]}
      {
        This:doUseAbil["Deadly Shot V", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[]
      }
      else
      {
        This:doUseAbil["Deadly Shot V", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[Deadly Shot V]
      }
    }
    elseif ${combo.Equal[Whisper of the Wind]}
    {
      if ${This.lastAbilUsed.Equal[Blade of Summer V]}
      {
        This:doUseAbil["Strike of the Winds", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[]
      }
      else
      {
        This:doUseAbil["Blade of Summer V", ${Me.Target.ID}]
        if ${This.didAction}
          This.lastAbilUsed:Set[Blade of Summer V]
      }
    }
  }
  
  member:string abilRegTest(string abilName)
  {
    variable string toCastAbil
    ; first need to strip off the roman numerals
    if ${abilName.Find[Superior]}
      toCastAbil:Set[${abilName.Right[${Math.Calc[${abilName.Length}-9]}]}]
    elseif ${abilName.Right[4].Equal[VIII]}
      toCastAbil:Set[${abilName.Left[${Math.Calc[${abilName.Length}-5]}]}]
    elseif ${abilName.Right[3].Equal[III]} || ${abilName.Right[3].Equal[VII]}
      toCastAbil:Set[${abilName.Left[${Math.Calc[${abilName.Length}-4]}]}]
    elseif ${abilName.Right[2].Equal[II]} || ${abilName.Right[2].Equal[IV]} || ${abilName.Right[2].Equal[VI]} || ${abilName.Right[2].Equal[IX]} || ${abilName.Right[2].Equal[XI]}
      toCastAbil:Set[${abilName.Left[${Math.Calc[${abilName.Length}-3]}]}]
    elseif ${abilName.Right[1].Equal[I]} || ${abilName.Right[1].Equal[V]} || ${abilName.Right[1].Equal[X]}
      toCastAbil:Set[${abilName.Left[${Math.Calc[${abilName.Length}-2]}]}]
    ; second is to look if that ability has an exception
    echo --- abilRegTest --- checking if ${toCastAbil} has an exception
    echo --- abilRegTest --- no exception, checking ${toCastAbil} ranks available
    ; third (if no exception) is to go down the roman numerals
    if ${Me.Ability[Superior ${toCastAbil}](exists)}
      toCastAbil:Set[Superior ${toCastAbil}]
    elseif ${Me.Ability[${toCastAbil} XI](exists)}
      toCastAbil:Set[${toCastAbil} XI]
    elseif ${Me.Ability[${toCastAbil} X](exists)}
      toCastAbil:Set[${toCastAbil} X]
    elseif ${Me.Ability[${toCastAbil} IX](exists)}
      toCastAbil:Set[${toCastAbil} IX]
    elseif ${Me.Ability[${toCastAbil} VIII](exists)}
      toCastAbil:Set[${toCastAbil} VIII]
    elseif ${Me.Ability[${toCastAbil} VII](exists)}
      toCastAbil:Set[${toCastAbil} VII]
    elseif ${Me.Ability[${toCastAbil} VI](exists)}
      toCastAbil:Set[${toCastAbil} VI]
    elseif ${Me.Ability[${toCastAbil} V](exists)}
      toCastAbil:Set[${toCastAbil} V]
    elseif ${Me.Ability[${toCastAbil} IV](exists)}
      toCastAbil:Set[${toCastAbil} IV]
    elseif ${Me.Ability[${toCastAbil} III](exists)}
      toCastAbil:Set[${toCastAbil} III]
    elseif ${Me.Ability[${toCastAbil} II](exists)}
      toCastAbil:Set[${toCastAbil} II]
    elseif ${Me.Ability[${toCastAbil} I](exists)}
      toCastAbil:Set[${toCastAbil} I]
  }
  
  
}

